<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>运行时配置</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="memcache.installation.html">安装</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="memcache.resources.html">资源类型</a></div>
 <div class="up"><a href="memcache.setup.html">安装／配置</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="memcache.ini" class="section">
 <h2 class="title">运行时配置</h2>
 <p class="simpara">
这些函数的行为受 <var class="filename">php.ini</var> 中的设置影响。
</p>
 <p class="para">
  <table class="doctable table">
   <caption><strong>Memcache配置选项</strong></caption>
   
    <thead>
     <tr>
      <th>名字</th>
      <th>默认</th>
      <th>可修改范围</th>
      <th>更新日志</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td><a href="memcache.ini.html#ini.memcache.allow-failover" class="link">memcache.allow_failover</a></td>
      <td>&quot;1&quot;</td>
      <td>PHP_INI_ALL</td>
      <td>Available since memcache 2.0.2.</td>
     </tr>

     <tr>
      <td><a href="memcache.ini.html#ini.memcache.max-failover-attempts" class="link">memcache.max_failover_attempts</a></td>
      <td>&quot;20&quot;</td>
      <td>PHP_INI_ALL</td>
      <td>Available since memcache 2.1.0.</td>
     </tr>

     <tr>
      <td><a href="memcache.ini.html#ini.memcache.chunk-size" class="link">memcache.chunk_size</a></td>
      <td>&quot;8192&quot;</td>
      <td>PHP_INI_ALL</td>
      <td>Available since memcache 2.0.2.</td>
     </tr>

     <tr>
      <td><a href="memcache.ini.html#ini.memcache.default-port" class="link">memcache.default_port</a></td>
      <td>&quot;11211&quot;</td>
      <td>PHP_INI_ALL</td>
      <td>Available since memcache 2.0.2.</td>
     </tr>

     <tr>
      <td><a href="memcache.ini.html#ini.memcache.hash-strategy" class="link">memcache.hash_strategy</a></td>
      <td>&quot;standard&quot;</td>
      <td>PHP_INI_ALL</td>
      <td>Available since memcache 2.2.0.</td>
     </tr>

     <tr>
      <td><a href="memcache.ini.html#ini.memcache.hash-function" class="link">memcache.hash_function</a></td>
      <td>&quot;crc32&quot;</td>
      <td>PHP_INI_ALL</td>
      <td>Available since memcache 2.2.0.</td>
     </tr>

     <tr>
      <td><a href="session.configuration.html#ini.session.save-handler" class="link">session.save_handler</a></td>
      <td>&quot;files&quot;</td>
      <td>PHP_INI_ALL</td>
      <td>Supported since memcache 2.1.2</td>
     </tr>

     <tr>
      <td><a href="session.configuration.html#ini.session.save-path" class="link">session.save_path</a></td>
      <td>&quot;&quot;</td>
      <td>PHP_INI_ALL</td>
      <td>Supported since memcache 2.1.2</td>
     </tr>

      <tr>
      <td><a href="memcache.ini.html#ini.memcache.protocol" class="link">memcache.protocol</a></td>
      <td>ascii</td>
      <td>&gt;PHP_INI_ALL</td>
      <td>Supported since memcache 3.0.0</td>
     </tr>

     <tr>
      <td><a href="memcache.ini.html#ini.memcache.redundancy" class="link">memcache.redundancy</a></td>
      <td>1</td>
      <td>&gt;PHP_INI_ALL</td>
      <td>Supported since memcache 3.0.0</td>
     </tr>

     <tr>
      <td><a href="memcache.ini.html#ini.memcache.session-redundancy" class="link">memcache.session_redundancy</a></td>
      <td>2</td>
      <td>&gt;PHP_INI_ALL</td>
      <td>Supported since memcache 3.0.0</td>
     </tr>

     <tr>
      <td><a href="memcache.ini.html#ini.memcache.compress-threshold" class="link">memcache.compress_threshold</a></td>
      <td>20000</td>
      <td>&gt;PHP_INI_ALL</td>
      <td>Supported since memcache 3.0.3</td>
     </tr>

     <tr>
      <td><a href="memcache.ini.html#ini.memcache.lock-timeout" class="link">memcache.lock_timeout</a></td>
      <td>15</td>
      <td>&gt;PHP_INI_ALL</td>
      <td>Supported since memcache 3.0.4</td>
     </tr>

    </tbody>
   
  </table>

  有关 PHP_INI_* 样式的更多详情与定义，见 <a href="configuration.changes.modes.html" class="xref">配置可被设定范围</a>。
 </p>

<p class="para">这是配置指令的简短说明。</p>

<p class="para">
 <dl>

  
  
   <dt id="ini.memcache.allow-failover">
    <em><code class="parameter">memcache.allow_failover</code></em>
    <span class="type"><a href="language.types.boolean.html" class="type boolean">boolean</a></span>
   </dt>

   <dd>

    <p class="para">
     是否在发生错误时（对用户）透明的转移到其他服务器。
    </p>
   </dd>

  
  
  
   <dt id="ini.memcache.max-failover-attempts">
    <em><code class="parameter">memcache.max_failover_attempts</code></em>
    <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>
   </dt>

   <dd>

    <p class="para">
    定义在写入和获取数据时最多尝试的服务器次数（即：故障转移最大尝试数），仅和
    memcache.allow_failover结合使用。
    </p>
   </dd>

  
  
  
   <dt id="ini.memcache.chunk-size">
    <em><code class="parameter">memcache.chunk_size</code></em>
    <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>
   </dt>

   <dd>

    <p class="para">
    数据传输块大小，这个值越小网络I/O次数越多，如果发现莫名的速度降低， 可以尝试将此值调至32768。
    </p>
   </dd>

  
  
  
   <dt id="ini.memcache.default-port">
    <em><code class="parameter">memcache.default_port</code></em>
    <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
   </dt>

   <dd>

    <p class="para">
    在尝试连接memcache的时候如果没有单独指定端口默认使用的TCP端口号。
    </p>
   </dd>

  

  
   <dt id="ini.memcache.hash-strategy">
    <em><code class="parameter">memcache.hash_strategy</code></em>
    <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
   </dt>

   <dd>

    <p class="para">
    控制key到服务器的映射（分布式）策略。值 
     <em>consistent</em>允许服务器增减而不会（大量）导致健的重新映射
     （译注：参见http://tech.idv2.com/2008/07/24/memcached-004/），设置为
     <em>standard</em>则使用余数方式进行key的映射。
    </p>
   </dd>

  
  
  
   <dt id="ini.memcache.hash-function">
    <em><code class="parameter">memcache.hash_function</code></em>
    <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
   </dt>

   <dd>

    <p class="para">
    控制在key-server映射时使用哪个hash函数<em>crc32</em> 
    标明使用标准CRC32进行hash，<em>fnv</em>则说明使用FNV-1a。
    </p>
   </dd>

  

  
   <dt id="ini.memcache.session-handler">
    <em><code class="parameter">session.save_handler</code></em>
    <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
   </dt>

   <dd>

    <p class="para">
    当值为<em>memcache</em>时标记使用memcache作为session处理器。
    </p>
   </dd>

  

  
   <dt id="ini.memcache.save-path">
    <em><code class="parameter">session.save_path</code></em>
    <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
   </dt>

   <dd>

    <p class="para">
    定义一个逗号分割的用于session存储的服务器url列表，例如：
     <em>&quot;tcp://host1:11211, tcp://host2:11211&quot;</em>.
    </p>
    <p class="para">
    每个url可以包含参数，这些参数于方法<span class="function"><a href="memcache.addserver.html" class="function">Memcache::addServer()</a></span>的参数相同。比如： 
     <em>&quot;tcp://host1:11211?persistent=1&amp;weight=1&amp;timeout=1&amp;retry_interval=15&quot;</em>
    </p>
   </dd>

  

  
   <dt id="ini.memcache.protocol">
    <em><code class="parameter">memcache.protocol</code></em>
    <span class="type"><a href="language.types.string.html" class="type string">string</a></span>
   </dt>

   <dd>

    <p class="para">
     
    </p>
   </dd>

  

  
   <dt id="ini.memcache.redundancy">
    <em><code class="parameter">memcache.redundancy</code></em>
    <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>
   </dt>

   <dd>

    <p class="para">
     
    </p>
   </dd>

  

  
   <dt id="ini.memcache.session-redundancy">
    <em><code class="parameter">memcache.session_redundancy</code></em>
    <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>
   </dt>

   <dd>

    <p class="para">
     
    </p>
   </dd>

  

  
   <dt id="ini.memcache.compress-threshold">
    <em><code class="parameter">memcache.compress_threshold</code></em>
    <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>
   </dt>

   <dd>

    <p class="para">
     
    </p>
   </dd>

  

  
   <dt id="ini.memcache.lock-timeout">
    <em><code class="parameter">memcache.lock_timeout</code></em>
    <span class="type"><a href="language.types.integer.html" class="type integer">integer</a></span>
   </dt>

   <dd>

    <p class="para">
     
    </p>
   </dd>

  
 </dl>

</p>
</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="memcache.installation.html">安装</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="memcache.resources.html">资源类型</a></div>
 <div class="up"><a href="memcache.setup.html">安装／配置</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
